package com.xt.dao;

import com.xt.bean.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;

import java.util.Collection;

/**
 * Created by XT on 2018/5/3.
 */
public interface UserRepository extends MongoRepository<User, String> {
    User findBySchoolNumber(String schoolNumber);

    User findBySchoolNumberAndPwdAndStatusAndRoleType(String schoolNumber, String pwd, int status, int roleType);

    User findBySchoolNumberAndPwdAndStatusAndRoleTypeIn(String schoolNumber, String pwd, int status, Collection<Integer> roleType);

    Page<User> findByNameLikeAndDepartmentIdLike(String name, String departmentId, Pageable pageable);

    //根据角色类型
    Page<User> findByRoleType(Integer roleType, Pageable pageable);

    //根据角色类型 和 名字模糊匹配
    Page<User> findByRoleTypeAndNameLike(Integer roleType, String name, Pageable pageable);


    //根据角色类型和入学年份
    Page<User> findByRoleTypeAndEntranceYear(Integer roleType, String entranceYear, Pageable pageable);

    //根据角色类型和入学年份 和 名字模糊匹配
    Page<User> findByRoleTypeAndEntranceYearAndNameLike(Integer roleType, String entranceYear, String name, Pageable pageable);

    //根据角色类型，院系id
    Page<User> findByRoleTypeAndDepartmentId(Integer roleType, String departmentId, Pageable pageable);

    //根据角色类型，院系id 和 名字模糊匹配
    Page<User> findByRoleTypeAndDepartmentIdAndNameLike(Integer roleType, String departmentId, String name, Pageable pageable);


    //根据角色类型，院系id，入学年份查询用户
    Page<User> findByRoleTypeAndDepartmentIdAndEntranceYear(Integer roleType, String departmentId, String entranceYear, Pageable pageable);

    //根据角色类型，院系id，入学年份查询用户 和 名字模糊匹配
    Page<User> findByRoleTypeAndDepartmentIdAndEntranceYearAndNameLike(Integer roleType, String departmentId, String entranceYear, String name, Pageable pageable);

    //根据角色类型，班级id查询用户
    Page<User> findByRoleTypeAndClassId(Integer roleType, String classId, Pageable pageable);

    //根据角色类型，班级id查询用户 和 名字模糊匹配
    Page<User> findByRoleTypeAndClassIdAndNameLike(Integer roleType, String classId, String name, Pageable pageable);

    //根据角色类型，班级id，入学年份查询用户
    Page<User> findByRoleTypeAndClassIdAndEntranceYear(Integer roleType, String classId, String entranceYear, Pageable pageable);


    //根据角色类型，院系id，专业id，班级id，入学年份查询用户 和 名字模糊匹配
    Page<User> findByRoleTypeAndDepartmentIdLikeAndSpecialtyIdLikeAndClassIdLikeAndEntranceYearLikeAndNameLikeAndSchoolNumberLike(Integer roleType, String departmentId, String specialtyId, String classId, String entranceYear, String name, String schoolNumber, Pageable pageable);

    //根据角色类型，院系id，专业id，班级id，入学年份查询用户 和 名字模糊匹配
    Page<User> findByRoleTypeInAndDepartmentIdLikeAndSpecialtyIdLikeAndClassIdLikeAndEntranceYearLikeAndNameLikeAndSchoolNumberLike(Collection<Integer> roleType, String departmentId, String specialtyId, String classId, String entranceYear, String name, String schoolNumber, Pageable pageable);


//    @Query("select u from User u where u.name=:name")
//    Page<User> getUsersByName(@Param("name") String name, Pageable pageable);
}
